using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MailClient
{
    public partial class Settings : Form
    {
        private DavyMail form;
        private TextBox txtMotherServer;
        public Settings(DavyMail f, TextBox tb)
        {
            form = f;
            form.Enabled = false;
            InitializeComponent();
            txtMotherServer = tb;
            txtServer.Enabled = false;

        }

        private void cmbServer_SelectedIndexChanged(object sender, EventArgs e)
        {
            String s = "" + cmbServer.SelectedItem;
            txtServer.Enabled=false;
            if (s.Equals("Telenet"))
            {
                txtServer.Text = "uit.telenet.be";
            }
            if (s.Equals("Scarlet"))
            {
                txtServer.Text = "smtp.scarlet.be";
            }
            if (s.Equals("Skynet (Adsl)"))
            {
                txtServer.Text = "relay.adsl.be";
            }
            if (s.Equals("Kotnet"))
            {
                txtServer.Text = "smtp.kuleuven.be";
            }
            if (s.Equals("Tiscali"))
            {
                txtServer.Text = "mail.tiscali.be";
            }
            if (s.Equals("UPC/chello"))
            {
                txtServer.Text = "relay.chello.be";
            }
            if (s.Equals("Planet Internet"))
            {
                txtServer.Text = "mailhost.pi.be";
            }
            if (s.Equals("Wanadoo"))
            {
                txtServer.Text = "smtp.wanadoo.be";
            }
            if (s.Equals("Online"))
            {
                txtServer.Text = "relay.online.be";
            }
            if (s.Equals("XS4all"))
            {
                txtServer.Text = "smtp.xs4all.be";
            }

            if (s.Equals("Other"))
            {
                txtServer.Enabled=true;
                txtServer.Text = "";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String s = txtServer.Text;

            if (s == null || s.Equals(""))
            { }
            else
            {
                txtMotherServer.Text = s;
                this.writeFile(s);
            }
            form.Enabled = true;
            this.Close();
        }
        private void writeFile(String s)
        {
            System.IO.FileInfo fileInfo = new System.IO.FileInfo("settings.dat");
            System.IO.StreamWriter smtpInfo = fileInfo.CreateText();
            smtpInfo.WriteLine(txtMotherServer.Text);
            smtpInfo.Close();
        }

        
    }
}